package controllers

import (
	"t11Lib/t11Errors"
	"t11Lib/t11Web"
	"亚太-iot-服务器/biz/wxBiz"
	"亚太-iot-服务器/models"
)

type BaseController struct {
	t11Web.T11BaseController
}

func (self *BaseController) getWxUser() (*models.JwtToken, t11Errors.T11Error) {
	ck := self.Ctx.GetCookie("userId")
	if ck == "" {
		ck = self.GetString("userId")
	}
	if ck == "" {
		return nil, t11Errors.New("no wxUser found")
	}
	//不用判断用户是否存在，因为已经在token中验证过md5了，那么一定是合法的微信用户了
	return wxBiz.JwtBiz.ParseWxMpJwtToken(ck)
}
